package com.example.task1.ui.AllService.Gover;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.bean.GovernmentListBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class GovernmentListAdapter extends BaseAdapter<GovernmentListBean.RowsDTO> {

    private Context context;
    private List<GovernmentListBean.RowsDTO> mData = new ArrayList<>();
    private TextView tvTitle;
    private TextView tvContent;
    private TextView tvUndertaker;
    private TextView tvTime;

    public GovernmentListAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<GovernmentListBean.RowsDTO> rows) {
        int size = mData.size();
        mData.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.governmentlist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<GovernmentListBean.RowsDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, GovernmentListBean.RowsDTO date) {
        tvContent.setText(date.getContent());
        tvTime.setText(date.getCreateTime());
        tvUndertaker.setText(date.getUndertaker());
        tvTitle.setText(date.getTitle());
    }

    @Override
    protected void holder(View view) {
        initView(view);
    }

    private void initView(View view) {
        tvTitle = view.findViewById(R.id.tv_title);
        tvContent = view.findViewById(R.id.tv_content);
        tvUndertaker = view.findViewById(R.id.tv_undertaker);
        tvTime = view.findViewById(R.id.tv_time);
    }
}
